/*
 * 
 * LegendShop 多用户商城系统
 * 
 *  版权所有,并保留所有权利。
 * 
 */
package com.legendshop.oa.service.impl;

import java.util.List;

import com.legendshop.dao.support.CriteriaQuery;
import com.legendshop.dao.support.PageSupport;
import com.legendshop.oa.dao.AttachmentTreeDao;
import com.legendshop.oa.model.AttachmentTree;
import com.legendshop.oa.service.AttachmentTreeService;
import com.legendshop.util.AppUtils;

/**
 * 附件树目录
 */
public class AttachmentTreeServiceImpl  implements AttachmentTreeService{
    private AttachmentTreeDao attachmentTreeDao;

    public void setAttachmentTreeDao(AttachmentTreeDao attachmentTreeDao) {
        this.attachmentTreeDao = attachmentTreeDao;
    }

    public List<AttachmentTree> getAttachmentTree(String userName) {
        return attachmentTreeDao.getAttachmentTree(userName);
    }

    public AttachmentTree getAttachmentTree(Long id) {
        return attachmentTreeDao.getAttachmentTree(id);
    }

    public void deleteAttachmentTree(AttachmentTree attachmentTree) {
        attachmentTreeDao.deleteAttachmentTree(attachmentTree);
    }

    public Long saveAttachmentTree(AttachmentTree attachmentTree) {
        if (!AppUtils.isBlank(attachmentTree.getId())) {
            updateAttachmentTree(attachmentTree);
            return attachmentTree.getId();
        }
        return attachmentTreeDao.saveAttachmentTree(attachmentTree);
    }

    public void updateAttachmentTree(AttachmentTree attachmentTree) {
        attachmentTreeDao.updateAttachmentTree(attachmentTree);
    }

    public PageSupport getAttachmentTree(CriteriaQuery cq) {
        return attachmentTreeDao.getAttachmentTree(cq);
    }

	@Override
	public List<AttachmentTree> getAttachmentTreeByPid(Long pId, String userName) {
		return attachmentTreeDao.getAttachmentTreeByPid(pId, userName);
	}

	@Override
	public void updateAttmntTreeNameById(Integer id, String name) {
		attachmentTreeDao.updateAttmntTreeNameById(id, name);
	}

	@Override
	public AttachmentTree getAttachmentTree(Long treeId, Long shopId) {
		return attachmentTreeDao.getAttachmentTree(treeId,shopId);
	}

	@Override
	public List<AttachmentTree> getAllChildByTreeId(Long treeId) {
		return attachmentTreeDao.getAllChildByTreeId(treeId);
	}

	@Override
	public void deleteAttachmentTree(List<AttachmentTree> attmntTreeList) {
		attachmentTreeDao.delete(attmntTreeList);
	}
}
